const image = document.getElementById('target');

// 获取原始图
fetch('/images/tortoise.png')
// 返回读取流
.then(response => response.body)
// 从原始图像创建灰度流
.then(rs => rs.pipeThrough(new TransformStream(new GrayscalePNGTransformer())))
// 从流中创建新的响应
.then(rs => new Response(rs))
// 从响应中创建一个 object url
.then(response => response.blob())
.then(blob => URL.createObjectURL(blob))
// 更新图片
.then(url => image.src = url)
.catch(console.error);